package logic

import (
	"com.wen/dal/db"
	"com.wen/model"
	"fmt"
)

func GetAllCategoryList() (categoryList []*model.Category, err error) {
	//1. 从数据库中，获取文章分类列表
	categoryList, err = db.GetAllCategoryList()
	if err != nil {
		fmt.Printf("1 get article list failed, err:%v\n", err)
		return
	}

	return
}

func GetRelativeAricleList(articleId int64) (articleList []*model.RelativeArticle, err error) {

	articleList, err = db.GetRelativeArticle(articleId)
	return
}

func GetPrevAndNextArticleInfo(articleId int64) (prevArticle *model.RelativeArticle,
	nextArticle *model.RelativeArticle, err error) {

	prevArticle, err = db.GetPrevArticleById(articleId)
	if err != nil {
		//打印一个警告日志
	}

	nextArticle, err = db.GetNextArticleById(articleId)
	if err != nil {
		//打印一个警告日志
	}

	return
}
